package test.dao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import test.dao.mapper.HouseMapper;
import test.dao.model.House;
import test.dao.model.TypeEnum;

/**
 * @Description
 * @Author shaopeng
 * @Date 2021/6/23
 * @Version 1.0
 */
@Component
@RestController
@RequestMapping( {"124","12"})
public class MybatisC {

    @Autowired
    private HouseMapper houseMapper;

    @RequestMapping("key1")
    public Object insert(){
        String flingLinkInfo = "1";


        //mybatis-plus会在启动时对继承自baseMapper的dao,自动生成默认函数的sql注入configration中,这样执行时就可以直接使用了
//            com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parse
//        return houseDAO.selectById(1);
//        houseDAO.selectById(1);

        House house = new House();
        house.setLocation("地址");
        house.setPrice(11);
        house.setData(new House());
        house.setType(TypeEnum.big);
        houseMapper.insert(house);
        return house;
    }

    @RequestMapping("/s")
    public Object select(){
        //mybatis-plus会在启动时对继承自baseMapper的dao,自动生成默认函数的sql注入configration中,这样执行时就可以直接使用了
//            com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parse
//        return houseDAO.selectById(1);
//        houseDAO.selectById(1);
//        PageHelper.offsetPage(0, 10, false);
//        houseMapper.selectcou();
        houseMapper.selectcou();

//         PageHelper.count(() -> {
//            houseMapper.select(4l, null);
//            houseMapper.selectcou();
//        });
        return 1;
    }


    @RequestMapping("/d")
    public void delete(Long id){
        //mybatis-plus会在启动时对继承自baseMapper的dao,自动生成默认函数的sql注入configration中,这样执行时就可以直接使用了
//            com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parse
//        return houseDAO.selectById(1);
//        houseDAO.selectById(1);
        houseMapper.delete(id);
    }

}
